package com.demo3;

import java.util.ArrayList;

public class StudentUtil {
    private StudentUtil() {
    }

    //静态方法
    public static int getMaxAge(ArrayList<Student> list) {
        //1.定义一个参照物
        int max = list.get(0).getAge();
        //2.循环遍历
        for (int i = 1; i < list.size(); i++) {
            //i索引      list.get(i)元素/学生对象﹑我们还需要getAge获取到年龄之后再进行比较
            int age = list.get(i).getAge();
            if (age > max) {
                max = age;
            }
        }
        return max;
    }
}
